var bodyParser = require('body-parser');
var express = require('express');
var session = require('express-session');
var mongoose = require('mongoose');
var cookiePaser = require('body-parser');
var MongoStore = require('connect-mongo')(session);
var settings = require('./settings');
var path = require('path')

app = express();
app.use(bodyParser());
mongoose.connect(settings.db);
app.use(session({
  secret: settings.cookieSecret,
  key: settings.db,
  cookie: {maxAge: 1000 * 60 * 60 * 24 * 30},
  store: new MongoStore({
    url: settings.db
  })
}))
 
app.set('view engine','jade');
require('./models')
require('./routes/routes')(app);
app.use('/static',express.static('./static'))
var port = process.env.NODE_ENV != 'production' ? settings.devport : 80
app.listen(port, function(){
  console.log("port: ", port)
});
